//@author A0096566M
/*

	Unit tests for FileInterface class

*/

#include "../fileInterface.h"


TEST(fileInterfaceTest, getSetFileName)
{
	FileInterface fInt;
	fInt.setFileName("test");
	EXPECT_EQ(fInt.getFileName(),"test");
	fInt.setFileName("123");
	EXPECT_EQ(fInt.getFileName(),"123");
	fInt.setFileName("Taak.txt");
	EXPECT_EQ(fInt.getFileName(),"Taak.txt");
}

//Test for file I/O here.
TEST(fileInterfaceTest, fileIO)
{
	FileInterface* fInt = new FileInterface();;
	Records* rec = new Records();
	rec->initialize(fInt);
	fInt->setRecords(*rec);
	fInt->setFileName("test.txt");

	//Read empty
	fInt->readFile();
	EXPECT_EQ(rec->getRecordSize(),0);

	//Add data
	Task a;
	a.setTaskName("test");
	rec->addData(a);

	//Write to file
	//fInt->writeFile();records will call write.

	//Read Again
	fInt->readFile();
	EXPECT_EQ(rec->getRecordSize(),1);

	//Clear File
	//fInt->clearFile(); <- use records clear instead.
	rec->delDataAll();
	EXPECT_EQ(rec->getRecordSize(),0);

	//Read Again
	fInt->readFile();
	EXPECT_EQ(rec->getRecordSize(),0);

}
